#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms fo the GNU General Public License, v2
# /etc/init.d/xmr-stak
name="xmr-stak"
description="Unified all-in-one Monero miner"
pidfile=/run/xmr.pid
command=/usr/bin/xmr-stak
command_args="--cpu /etc/xmr-stak/cpu.config --amd /etc/xmr-stak/amd.config --nvidia /etc/xmr-stak/nvidia.config -c /etc/xmr-stak/main.config -C /etc/xmr-stak/pools.txt"
start_stop_daemon_args="--background --make-pidfile"

start_pre() {
	if [ ! -r /etc/xmr-stak/main.config ]; then
		eerror "/etc/xmr-stak/main.config is missing."
		errror "Run:"
		eerror "/usr/bin/xmr-stak --cpu /etc/xmr-stak/cpu.config --amd /etc/xmr-stak/amd.config --nvidia /etc/xmr-stak/nvidia.config -c /etc/xmr-stak/main.config -C /etc/xmr-stak/pools.txt"
		errror "xmr-stak can now be terminated and this service can be started"
		return 1
	fi
}

depend() {
	use dns net
}
